package com.meeting.model.enums;

/**
 * 支付方式枚举类
 */
public enum PaymentMethodEnum {

    ALIPAY(0, "支付宝"),
    WECHAT_PAY(1, "微信"),
    UNION_PAY(2, "银联");

    private final int code;
    private final String desc;

    PaymentMethodEnum(int code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public int getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    /**
     * 根据code获取对应的枚举值
     *
     * @param code 枚举值
     * @return 对应的枚举对象
     */
    public static PaymentMethodEnum fromCode(int code) {
        for (PaymentMethodEnum method : values()) {
            if (method.getCode() == code) {
                return method;
            }
        }
        throw new IllegalArgumentException("Invalid payment method code: " + code);
    }
}
